package com.example.drzhang.oengldemo.render;

import android.content.Context;
import android.opengl.GLES20;

import com.example.drzhang.oengldemo.R;

/**
 * Created by drzhang on 2018/1/10.
 */

public class ColorShaderProgram extends ShaderProgram {

    private int uMatrixLocation;

    private int aPosition;
    private int aColorLocation;


    protected ColorShaderProgram(Context context) {
        super(context, R.raw.sample_vertex_shader, R.raw.sample_fragment_shader);
        uMatrixLocation = GLES20.glGetUniformLocation(program, U_MATRIX);

        aPosition = GLES20.glGetAttribLocation(program, A_POSITION);
        aColorLocation = GLES20.glGetAttribLocation(program, A_COLOR);
    }

    public void setUniforms(float[] matrix, int textureId) {
        GLES20.glUniformMatrix4fv(uMatrixLocation, 1, false, matrix, 0);
    }

    public int getPositionAttributeLocation() {
        return aPosition;
    }

    public int getColorAttributeLocation() {
        return aColorLocation;
    }

}
